﻿@using XRepair.Conventions.Enum
@using xCache = MvcXRepairAdmin.CacheData

@model XRepair.Models.Service

@{
    Layout = null;
    var deviceTypes = new List<SelectListItem>
    {
        new SelectListItem{Value="", Selected=true, Text="Select type of device"},
        new SelectListItem{Value=DeviceTypes.Laptop.ToString(), Selected=true, Text="Laptop"},
        new SelectListItem{Value=DeviceTypes.Mobile.ToString(), Selected=true, Text="Mobile"},
    };

    var symptomList = xCache.Cache.GetAllActiveSymptoms();

    List<SelectListItem> symptomSelectList = symptomList.Select(x => new SelectListItem { Value = x.ID.Value.ToString(), Text = x.Name }).ToList();
    symptomSelectList.Insert(0, new SelectListItem { Value = string.Empty, Text = "Select symptom", Selected = true });
    
}

@using (Html.BeginForm("Edit", "Service", FormMethod.Post))
{
    @Html.ValidationSummary(true)
    <table>
        <tbody>
            <tr>
                <td>Device Type</td>
                <td>
                    @Html.DropDownListFor(x => x.DeviceTypeID, deviceTypes)</td>
            </tr>

            <tr>
                <td>Symptom</td>
                <td>
                    @Html.DropDownListFor(x => x.SymptomTypeID, symptomSelectList) </td>
            </tr>

            <tr>
                <td>Service Name</td>
                <td>
                    @Html.TextBoxFor(x => x.ServiceName) </td>
            </tr>

            <tr>
                <td>Description</td>

                <td>
                    @Html.TextAreaFor(x => x.ServiceDescription, new { cols = 5, rows = 5 })
                </td>
            </tr>

            <tr>
                <td>Labor Cost</td>
                <td>
                    @Html.TextBoxFor(x => x.LaborCost)
                </td>
            </tr>

            <tr>
                <td>Labor Discount</td>
                <td>
                    @Html.TextBoxFor(x => x.DiscountLabor)</td>
            </tr>

            <tr>
                <td>Part Cost</td>
                <td>
                    @Html.TextBoxFor(x => x.PartCost)</td>
            </tr>

            <tr>
                <td>Part Discount</td>
                <td>
                    @Html.TextBoxFor(x => x.DiscountPart)</td>
            </tr>
        </tbody>
    </table>
    
    @Html.HiddenFor(x => x.ID);
    
    <input type="submit" value="Update" /><input type="button" value="Cancel" id="btnCancelEdit" />
    
    
}
